// components/supply-list/supply-list.js
import {Location} from '../../util/location'
const location = new Location()

Component({
  properties: {
    data: {
      type: Object,
      value: {}
    }
  },


  data : {
    data: {}
  },

  methods: {
    call () {
      wx.makePhoneCall({
        phoneNumber: this.properties.data.phone
      })
    },

    toMap(event){
        location.geocoder(event.target.dataset.address).then(res=>{
        if(!res.message){
          let latitude = res.lat
          let longitude = res.lng
          wx.openLocation({
            latitude: latitude,
            longitude: longitude,
            scale: 28
          })
        }else{
          wx.showToast({
            title: res.message,
            icon: 'none'
          })
        }
      })
    }
  }
})
